package com.hkts.flow.manager.exceptiohandler;

import com.hkts.flow.manager.utils.Result;
import com.hkts.flow.manager.utils.ResultUtil;
import groovy.util.logging.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassNameControllerExceptionHandler
 * @Description
 * @Author yck
 * @Date2020-12-24 14:24
 * @Version V1.0
 **/
/*@Slf4j
@RestControllerAdvice*/
public class ControllerExceptionHandler {
    /*@ExceptionHandler(Exception.class)
    @ResponseStatus(value = HttpStatus.OK)*/
    public Result<Object> handleException(Exception e) {

        String errorMsg = "exception";
        if (e!=null){
            errorMsg = e.getMessage();
            System.out.println(errorMsg);
        }
        return new ResultUtil<>().setErrorMsg(500, errorMsg);
    }
}

